package product.nutz;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

public class Qwikioffice {

	@At("/service")
	@Ok("json")
    public Map service(@Param("method")String method,@Param("moduleId")String moduleId) {
		Map map  = new HashMap();
		if(method!=null && method.equals("load")){
			map = load(moduleId);
		}
		return map;
	}
	
	private Map load(String moduleId){
		Map map  = new HashMap();
		String filePath = "E:/workspace/istudy/resource/js/qwikioffice/loadModel.js";
		File file = new File(filePath);
		String fileContent = "";
		try {
			fileContent = FileUtils.readFileToString(file, "utf-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
		map.put("responseText",fileContent);
		return map;
	}
	private void out(Object object){
		System.out.println(object);
	}
	
}
